#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main(){
	int arr[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int y = 0, m = 0, n = 0, i = 0;
	scanf("%d/%d/%d", &y, &m, &n);
	if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0){
		arr[2] = 29;
	}
	for (i = 0; i < m; i++){
		n += arr[i];
	}
	printf("%d", n);

	return 0;
}